{% extends "base.html" %}

{% block title %}权限管理 - 网站管理后台{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">权限管理</h1>
    <div class="btn-toolbar mb-2 mb-md-0">
        <div class="btn-group me-2">
            <a href="{{ url_for('web.add_permission') }}" class="btn btn-sm btn-outline-secondary">
                <i class="fas fa-plus"></i> 添加权限
            </a>
        </div>
    </div>
</div>

<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>权限名称</th>
                <th>权限标识符</th>
                <th>描述</th>
                <th>分类</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for permission in permissions %}
            <tr>
                <td>{{ permission[0] }}</td>
                <td>{{ permission[1] }}</td>
                <td>{{ permission[2] }}</td>
                <td>{{ permission[3] or '-' }}</td>
                <td>{{ permission[4] or '-' }}</td>
                <td>{{ permission[5] }}</td>
                <td>
                    <a href="{{ url_for('web.edit_permission', permission_id=permission[0]) }}" class="btn btn-sm btn-outline-primary">
                        <i class="fas fa-edit"></i> 编辑
                    </a>
                    <form action="{{ url_for('web.delete_permission', permission_id=permission[0]) }}" method="POST" style="display: inline;">
                        <button type="submit" class="btn btn-sm btn-outline-danger" 
                                onclick="return confirm('确定要删除这个权限吗？')">
                            <i class="fas fa-trash"></i> 删除
                        </button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}